<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="/jsp/inc/header.jsp" %>
<c:set var="title" value="picture"/>
<c:set var="rootpath" value="${CONTEXT_PATH}/admin/resource/picture"/>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="${STATIC_HOST}/css/ligerui.css" rel="stylesheet" type="text/css"/>
    <link href="${STATIC_HOST}/css/common.css" rel="stylesheet" type="text/css" />
    <script src="${STATIC_HOST}/js/common.js" type="text/javascript"></script>
    <script src="${STATIC_HOST}/js/LG.js" type="text/javascript"></script>
    <title>${title}管理</title>
</head>
<body class="listbody">

	<!-- 导航开始 -->
	<div class="withicon">
		<span><b>当前位置：内容 &gt; <a href="list.do?view=${view}">${title}管理</a></b></span>
	</div>
	<!-- 导航结束 -->
	
	<!-- 搜索开始 -->
	<div id="mainsearch" class="l-panel">
		<div class="searchtitle l-panel-topbar"><span>搜索</span><img src="${STATIC_HOST}/images/common/searchtool.gif"><div class="togglebtn"></div></div>
		<div class="searchbox">
		<form action="${rootpath}/list.do" method="post" name="searchForm" id="searchForm">
		<ul>
		   <li class="li_search_left"><label for="eqId">id</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqId" id="eqId" size="10" ltype='text' ligerui='{"width":100}'  value="${eqId}"/>
		  </li> 
		   <li class="li_search_left"><label for="eqSiteId">siteId</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqSiteId" id="eqSiteId" size="10" ltype='text' ligerui='{"width":100}'  value="${eqSiteId}"/>
		  </li> 
		   <li class="li_search_left"><label for="eqTitle">title</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqTitle" id="eqTitle" size="10" ltype='text' ligerui='{"width":100}'  value="${eqTitle}"/>
		  </li> 
		
		  <div style="clear:both; padding-top:10px; display:none" id="advsearchdiv"><!--更多搜索开始-->
		   <li class="li_search_left"><label for="eqExtName">extName</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqExtName" id="eqExtName" size="10" ltype='text' ligerui='{"width":100}'  value="${eqExtName}"/>
		  </li> 
		   <li class="li_search_left"><label for="eqHost">host</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqHost" id="eqHost" size="10" ltype='text' ligerui='{"width":100}'  value="${eqHost}"/>
		  </li> 
		   <li class="li_search_left"><label for="eqPath">path</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqPath" id="eqPath" size="10" ltype='text' ligerui='{"width":100}'  value="${eqPath}"/>
		  </li> 
		   <li class="li_search_left"><label for="eqHashcode">hashcode</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqHashcode" id="eqHashcode" size="10" ltype='text' ligerui='{"width":100}'  value="${eqHashcode}"/>
		  </li> 
		   <li class="li_search_left"><label for="eqWidth">width</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqWidth" id="eqWidth" size="10" ltype='text' ligerui='{"width":100}'  value="${eqWidth}"/>
		  </li> 
		   <li class="li_search_left"><label for="eqHeight">height</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqHeight" id="eqHeight" size="10" ltype='text' ligerui='{"width":100}'  value="${eqHeight}"/>
		  </li> 
		   <li class="li_search_left"><label for="eqFileSize">fileSize</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqFileSize" id="eqFileSize" size="10" ltype='text' ligerui='{"width":100}'  value="${eqFileSize}"/>
		  </li> 
		   <li class="li_search_left"><label for="eqStatus">status</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqStatus" id="eqStatus" size="10" ltype='text' ligerui='{"width":100}'  value="${eqStatus}"/>
		  </li> 
		   <li class="li_search_left"><label for="eqCreateTime">createTime</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqCreateTime" id="eqCreateTime" size="10" ltype='text' ligerui='{"width":100}'  value="${eqCreateTime}"/>
		  </li> 
		   <li class="li_search_left"><label for="eqCreateUserId">createUserId</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqCreateUserId" id="eqCreateUserId" size="10" ltype='text' ligerui='{"width":100}'  value="${eqCreateUserId}"/>
		  </li> 
		   <li class="li_search_left"><label for="eqModifyTime">modifyTime</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqModifyTime" id="eqModifyTime" size="10" ltype='text' ligerui='{"width":100}'  value="${eqModifyTime}"/>
		  </li> 
		   <li class="li_search_left"><label for="eqModifyUserId">modifyUserId</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqModifyUserId" id="eqModifyUserId" size="10" ltype='text' ligerui='{"width":100}'  value="${eqModifyUserId}"/>
		  </li> 
		   <li class="li_search_left"><label for="eqOriginalUrl">originalUrl</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqOriginalUrl" id="eqOriginalUrl" size="10" ltype='text' ligerui='{"width":100}'  value="${eqOriginalUrl}"/>
		  </li> 
		   <li class="li_search_left"><label for="eqMemo">memo</label>：</li>
			   <li class="li_search_right">
			<input type="text" name="eqMemo" id="eqMemo" size="10" ltype='text' ligerui='{"width":100}'  value="${eqMemo}"/>
		  </li> 
			<li style="clear:both; padding-top:10px;"></li><!--换行-->
		  </div><!--更多搜索结束-->

		<li class="li_searchbutton">
		  <div id="searchbutton" class="button button2 buttonnoicon">
			<div class="button-l"></div>
			<div class="button-r"></div>
			<span>搜索</span>
		  </div>
		  <div class="div_advsearchbutton"></div>
		  <div id="advsearchbutton">
			<span>更多搜索</span>
		  </div>
		</li>
		</ul>
	  </form>
	  </div>
	</div>
	<!-- 搜索结束 -->   
	
	<div class="div_newline"></div>
	
	<!-- 列表开始 -->
	<div id="maingrid"></div> 
	<!-- 列表结束 -->
	
	<script type="text/javascript">
		//查看
		function show(id){
			jQuery("#view").val('/admin/resource/picture/show');
			submitReq("${rootpath}/show.do?id="+id);
		}
		//编辑
		function edit(id){
			jQuery("#view").val('');
			submitReq("${rootpath}/edit.do?id="+id);
		}
		//新建
		function newObject(){
			jQuery("#view").val('');
			submitReq("${rootpath}/edit.do");
		}
		//获取选择ID
		function getSelectedId(){
			var selecteds = grid.getSelecteds();
			if (selecteds.length==0) { 
				return "";
			}
			var ids="";
			for(var key in selecteds){
				ids += (","+selecteds[key].id);
			}
			return ids.substring(1);
		}
		//删除
		function del(id){
			var path = "${rootpath}/delete.do";
			if( !isNaN(id) ){
				path += "?eqId=" + id;
			}else{
				var ids = getSelectedId();
				if (ids.length==0) { 
					LG.tip('请选择要删除的行!'); 
					return;
				}
				path += "?inIds=" + ids;
			}
			$.ligerDialog.confirm("确定要删除吗？", function (yes) {
				if( yes ) submitReq(path);
			});
		}
		//批量删除
		function batchDelete(){
			del();
		}
		//无效
		function auditNotPass(){
			updateStatus( 0 );
		}
		//有效
		function auditPass(){
			updateStatus( 1 );
		}
		//更新状态
		function updateStatus(statusValue,id){
			var path = "${rootpath}/updateStatus.do?status="+statusValue;
			if( !isNaN(id) ){
				path += "&eqId=" + id;
			}else{
				var ids = getSelectedId();
				if (ids.length==0) { 
					LG.tip('请选择要更新的行!'); 
					return;
				}
				path += "&inIds=" + ids;
			}
			$.ligerDialog.confirm("确定要操作吗？", function (yes) {
				if( yes ) submitReq(path);
			});
		}
		//提交
		function submitReq(path,query,notsubmit){
			pageFormObj = document.pageForm;
			pageFormObj.action = path;
			if(query){
				pageFormObj.queryParam.value = query;
			}
			if(!notsubmit){
				pageFormObj.submit();
			}
			return false;
		}
	
	
	//列表
	var grid = $("#maingrid").ligerGrid({
		
      columns: [
        { display:"id", name:"id", align: 'left', width: 80, type: 'int', frozen: true, render: function(row){
              return "<a href='javascript:show("+row.id+")'>"+row.id+"</a>";
            }
         },
	    { display:"siteId", name:"siteId", align: 'left', width: 100 ,type: 'int'},
	    { display:"title", name:"title", align: 'left', width: 100 },
	    { display:"fileName", name:"fileName", align: 'left', width: 100 },
	    { display:"extName", name:"extName", align: 'left', width: 100 },
	    { display:"host", name:"host", align: 'left', width: 100 },
	    { display:"path", name:"path", align: 'left', width: 100 },
	    { display:"hashcode", name:"hashcode", align: 'left', width: 100 },
	    { display:"width", name:"width", align: 'left', width: 100 ,type: 'int'},
	    { display:"height", name:"height", align: 'left', width: 100 ,type: 'int'},
	    { display:"fileSize", name:"fileSize", align: 'left', width: 100 ,type: 'int'},
	    { display:"createTime", name:"createTime", align: 'left', width: 100 ,type: 'date', hide:true },
	    { display:"createUserId", name:"createUserId", align: 'left', width: 100 ,type: 'int', hide:true },
	    { display:"modifyTime", name:"modifyTime", align: 'left', width: 100 ,type: 'date', hide:true },
	    { display:"modifyUserId", name:"modifyUserId", align: 'left', width: 100 ,type: 'int', hide:true },
	    { display:"originalUrl", name:"originalUrl", align: 'left', width: 100 , hide:true },
	    { display:"memo", name:"memo", align: 'left', width: 100 , hide:true },
        { display:"操作", minWidth: 150, isAllowHide: false, isSort: false, render: function(row){
            return '<img src="http://static.21cnimg.com/img/icons/content/show.gif" class="imgbtn" alt="查看" title="查看" onclick="show('+row.id+')" />'
              +'<img src="http://static.21cnimg.com/img/icons/content/edit.gif" class="imgbtn" alt="修改" title="修改" onclick="edit('+row.id+')" />'
              +'<img src="http://static.21cnimg.com/img/icons/content/audit.gif" class="imgbtn" alt="有效" title="有效" onclick="updateStatus(1, '+row.id+')" />'
              +'<img src="http://static.21cnimg.com/img/icons/silkicons/delete.png" class="imgbtn" alt="无效" title="无效" onclick="updateStatus(0, '+row.id+')" />'
              +'<img src="http://static.21cnimg.com/img/icons/content/delete2.gif" class="imgbtn" alt="删除" title="删除" onclick="del('+row.id+')" />';
           }
         }
      ],
      parms: [ {name:'_ajax', value:1}
          <c:if test="${not empty eqId}">, { name:'eqId',value:'${eqId}'}</c:if>
          <c:if test="${not empty eqSiteId}">, { name:'eqSiteId',value:'${eqSiteId}'}</c:if>
          <c:if test="${not empty eqTitle}">, { name:'eqTitle',value:'${eqTitle}'}</c:if>
          <c:if test="${not empty eqFileName}">, { name:'eqFileName',value:'${eqFileName}'}</c:if>
          <c:if test="${not empty eqExtName}">, { name:'eqExtName',value:'${eqExtName}'}</c:if>
          <c:if test="${not empty eqHost}">, { name:'eqHost',value:'${eqHost}'}</c:if>
          <c:if test="${not empty eqPath}">, { name:'eqPath',value:'${eqPath}'}</c:if>
          <c:if test="${not empty eqHashcode}">, { name:'eqHashcode',value:'${eqHashcode}'}</c:if>
          <c:if test="${not empty eqWidth}">, { name:'eqWidth',value:'${eqWidth}'}</c:if>
          <c:if test="${not empty eqHeight}">, { name:'eqHeight',value:'${eqHeight}'}</c:if>
          <c:if test="${not empty eqFileSize}">, { name:'eqFileSize',value:'${eqFileSize}'}</c:if>
          <c:if test="${not empty eqStatus}">, { name:'eqStatus',value:'${eqStatus}'}</c:if>
          <c:if test="${not empty eqCreateTime}">, { name:'eqCreateTime',value:'${eqCreateTime}'}</c:if>
          <c:if test="${not empty eqCreateUserId}">, { name:'eqCreateUserId',value:'${eqCreateUserId}'}</c:if>
          <c:if test="${not empty eqModifyTime}">, { name:'eqModifyTime',value:'${eqModifyTime}'}</c:if>
          <c:if test="${not empty eqModifyUserId}">, { name:'eqModifyUserId',value:'${eqModifyUserId}'}</c:if>
          <c:if test="${not empty eqOriginalUrl}">, { name:'eqOriginalUrl',value:'${eqOriginalUrl}'}</c:if>
          <c:if test="${not empty eqMemo}">, { name:'eqMemo',value:'${eqMemo}'}</c:if>
         ] ,
		toolbar: { items: [
		         { line: true }
                ,{ text: '有效', click: auditPass, img: 'http://static.21cnimg.com/img/icons/silkicons/accept.png' }
                ,{ line: true }
                ,{ text: '无效', click: auditNotPass, img: 'http://static.21cnimg.com/img/icons/silkicons/delete.png' }
                ,{ line: true }
                ,{ text: '删除', click: batchDelete, img: 'http://static.21cnimg.com/img/icons/silkicons/cross.png' }
                ,{ line: true }
                ,{ text: '新增', click: newObject, img: 'http://static.21cnimg.com/img/icons/silkicons/add.png' }
                ,{ line: true }
			] },
	    pageSize: ${pageSize}, pageSizeOptions:[5,10,20,40,60,80,100],
	    pageParmName:'pageNo', pagesizeParmName:'pageSize', sortnameParmName:'sortName',sortorderParmName:'sortOrder',
	    dataAction:'server', 
	    url: '${rootpath}/search.do',
	    rownumbers: true, checkbox: true, frozen: true , dateFormat:'yyyy-MM-dd hh:mm',
		width: '98%', height: '100%', rowHeight:25, fixedCellHeight: true, usePager: true
	});
	
	jQuery("#searchbutton").click(function(){
	    var params = '';
        var group = {};
		var form=$("#searchForm");
        $(":input", form).not(":submit, :reset, :image,:button, [disabled]").each(function (){
            if (!this.name) return;
            if ($(this).val() == null || $(this).val() == "") return;
            var ltype = $(this).attr("ltype");
            var optionsJSON = $(this).attr("ligerui"), options;
            if (optionsJSON){
                options = JSON2.parse(optionsJSON);
            }
            //get the value type(number or date)
            var value = $(this).val();
            var name = this.name;
            //如果是下拉框，那么读取下拉框关联的隐藏控件的值(ID值,常用与外表关联)
            if (ltype == "select" && options && options.valueFieldID){
                value = $("#" + options.valueFieldID).val();
                name = options.valueFieldID;
            }
            group[name]=value;
			params += ("&"+name+"="+encodeURIComponent(value));
        });
	    grid.set('parms', group);
        grid.loadData();
        $("#queryParam").val( params.substring(1) );
	});
	
	jQuery("#advsearchbutton").click(function(){
	    jQuery("#advsearchdiv").slideToggle('fast');
	});
	
	$("#eqStatus").val('${eqStatus}');//初始化下来菜单
	$("#searchForm").ligerForm();
	
	</script>
	
	<form action="${rootpath}/list.do" method="post"  name="pageForm" id="pageForm">
	  <input type="hidden" id="queryParam" name="queryParam" value="${queryParam}"/>
	  <input name="view" id="view" type="hidden" value="${view}"/>
	</form>
	
	<%@ include file="/jsp/inc/footer.jsp"%>
</body>
</html>